'''
Created on 2009-11-18

@author: Jialai_Zhu
'''
from maltree import malnode
from maltree import malxml
from maltree import mufs   
from maltree.downloader import urllib2Downloader 
def run(url): 
    tree=malxml.xmlmaltree(url)
    fs=mufs()
    try:
        hanlde=(fs.store_hanlde,tree.append)
        d=urllib2Downloader();
        malnode.through(malnode.node('root',url),hanlde,d)
        tree.toFile()
    except Exception,ex:
        print Exception,':',ex   
    
import getopt, sys
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "i:v", ["input="])
    except getopt.GetoptError:
        # print help information and exit:
        sys.exit(2)
    for o, a in opts:
        if o in ("-i", "--input"):
            run(a)    
    # ...
    
           
import string

if __name__ == "__main__":
    main()
#    run(r"http://www.37c.com.cn/institution/hospital/hospital03.asp?id=20669")
 